package com.ruoyi.course.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.course.domain.UserCourseScore;
import com.ruoyi.course.service.IUserCourseScoreService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 课程-用户-分数中间Controller
 * 
 * @author qzg
 * @date 2025-08-19
 */
@RestController
@RequestMapping("/course/score")
public class UserCourseScoreController extends BaseController
{
    @Autowired
    private IUserCourseScoreService userCourseScoreService;

    /**
     * 查询课程-用户-分数中间列表
     */
    @PreAuthorize("@ss.hasPermi('course:score:list')")
    @GetMapping("/list")
    public TableDataInfo list(UserCourseScore userCourseScore)
    {
        startPage();
        List<UserCourseScore> list = userCourseScoreService.selectUserCourseScoreList(userCourseScore);
        return getDataTable(list);
    }

    /**
     * 导出课程-用户-分数中间列表
     */
    @PreAuthorize("@ss.hasPermi('course:score:export')")
    @Log(title = "课程-用户-分数中间", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UserCourseScore userCourseScore)
    {
        List<UserCourseScore> list = userCourseScoreService.selectUserCourseScoreList(userCourseScore);
        ExcelUtil<UserCourseScore> util = new ExcelUtil<UserCourseScore>(UserCourseScore.class);
        util.exportExcel(response, list, "课程-用户-分数中间数据");
    }

    /**
     * 获取课程-用户-分数中间详细信息
     */
    @PreAuthorize("@ss.hasPermi('course:score:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(userCourseScoreService.selectUserCourseScoreById(id));
    }

    /**
     * 新增课程-用户-分数中间
     */
    @PreAuthorize("@ss.hasPermi('course:score:add')")
    @Log(title = "课程-用户-分数中间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UserCourseScore userCourseScore)
    {
        return toAjax(userCourseScoreService.insertUserCourseScore(userCourseScore));
    }

    /**
     * 修改课程-用户-分数中间
     */
    @PreAuthorize("@ss.hasPermi('course:score:edit')")
    @Log(title = "课程-用户-分数中间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UserCourseScore userCourseScore)
    {
        return toAjax(userCourseScoreService.updateUserCourseScore(userCourseScore));
    }

    /**
     * 删除课程-用户-分数中间
     */
    @PreAuthorize("@ss.hasPermi('course:score:remove')")
    @Log(title = "课程-用户-分数中间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(userCourseScoreService.deleteUserCourseScoreByIds(ids));
    }
}
